package com.allen.bill.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.allen.bill.service.FetchService;
import com.allen.bill.service.JobService;
import com.allen.bill.service.NoteLossService;

@Service
public class JobServiceImpl implements JobService {

    private static final Logger logger = LoggerFactory.getLogger(JobServiceImpl.class);
    
    @Autowired
    private FetchService fetchService;
    @Autowired
    private NoteLossService  noteLossService;
    
    @Override
    @Scheduled(cron="${cron.start}")
    public void work() {
        if(logger.isInfoEnabled()){
            logger.info("start work fetch....");
            fetchService.startFetch();
            logger.info("end work fetch....");
            
            try{
                logger.info("start transfer");
                noteLossService.insertTransferData();
                logger.info("end transfer");
            }catch (Exception e) {
               logger.error("transfer error",e);
            }
        }
    }

}
